#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read()
{
	int res=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){res=(res<<1)+(res<<3)+(c^48);c=getchar();}
	return res*f;
}
void write(int x)
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
int n,k,d;
int h[500005];
int t[500005];
int f[500005];
vector<pair<int,int> >v[500005];
int sum[500005];
struct Nene
{
	priority_queue<int>p,q;
	void insert(int x){q.push(x);}
	void del(int x){p.push(x);}
	int query()
	{
		while(p.size()&&p.top()==q.top()) q.pop(),p.pop();
		if(q.size()) return q.top();
		return -1e18;
	}
}heap[500005],ans;
signed main()
{
	freopen("holiday.in","r",stdin);
	freopen("holiday.out","w",stdout);
	n=read(),k=read(),d=read();
	for(int i=1;i<=n;i++) h[i]=read();
	for(int i=1;i<n;i++) t[i]=read();
	memset(f,-0x3f,sizeof f);
	f[1]=h[1];
	v[2+t[1]].push_back({1,f[1]});
	ans.insert(f[1]);heap[1%k].insert(f[1]);
	for(int i=2;i<=n;i++)
	{
		int p;
		for(int j=0;j<v[i].size();j++) 
		{
			p=v[i][j].first%k;
			ans.del(heap[p].query()-sum[p]);
			heap[p].del(v[i][j].second);
			if(heap[p].query()!=-1e18) ans.insert(heap[p].query()-sum[p]);
		}
		p=i%k;
		if(heap[p].query()!=-1e18) ans.del(heap[p].query()-sum[p]);
		sum[p]+=d;
		ans.insert(heap[p].query()-sum[p]);
		f[i]=ans.query()+h[i];
		ans.del(heap[p].query()-sum[p]);
		heap[p].insert(f[i]+sum[p]);
		ans.insert(heap[p].query()-sum[p]);
		v[i+t[i]+1].push_back({i,f[i]+sum[p]});
	}
	write(f[n]);
	return 0;
}
